﻿<Window x:Class="ScrumFactory.Windows.MessageBox"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:props="clr-namespace:ScrumFactory.Windows.Properties"
        x:Name="window"
        ShowInTaskbar="False"  
        WindowStartupLocation="CenterOwner"        
        Title="{Binding Title}"
        ResizeMode="NoResize"
        SizeToContent="WidthAndHeight" 
        Style="{StaticResource FactoryWindow}"
        MinHeight="150" Width="400" >  
    <Grid>
        <ContentControl x:Name="contentView" Content="{Binding ContentView}"/>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <Image Grid.Column="0" Grid.Row="0"               
               VerticalAlignment="Top"
               Source="{Binding ImageSource}"
               Width="32" Height="32" Stretch="Uniform" Margin="12">
                <Image.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ImageSource}" Value="{x:Null}">
                                <Setter Property="Image.Visibility" Value="Collapsed"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Image.Style>
            </Image>

            <TextBlock
            Grid.Column="1" Grid.Row="0" Margin="0,10,10,15"
            Text="{Binding Message}" TextWrapping="Wrap" Foreground="Black"/>



            <Border
                HorizontalAlignment="Stretch"
                Background="{StaticResource WindowButtonBar}"
                Grid.ColumnSpan="2" Grid.Row="1">
                <StackPanel HorizontalAlignment="Center" Orientation="Horizontal">

                    <Button
                    MinWidth="80" Margin="5" HorizontalAlignment="Center"
                    Content="Ok" Command="{Binding ResultButtonPressedCommand}" CommandParameter="OK">
                        <Button.Style>
                            <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
                                <Setter Property="Button.Visibility" Value="Collapsed"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Buttons}" Value="OK">
                                        <Setter Property="Button.Visibility" Value="Visible"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Buttons}" Value="OKCancel">
                                        <Setter Property="Button.Visibility" Value="Visible"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Button.Style>
                    </Button>
                    <Button
                    MinWidth="80" Margin="5" HorizontalAlignment="Center"
                    Content="{x:Static props:Resources.Yes}" Command="{Binding ResultButtonPressedCommand}" CommandParameter="Yes">
                        <Button.Style>
                            <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
                                <Setter Property="Button.Visibility" Value="Collapsed"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Buttons}" Value="YesNo">
                                        <Setter Property="Button.Visibility" Value="Visible"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Buttons}" Value="YesNoCancel">
                                        <Setter Property="Button.Visibility" Value="Visible"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Button.Style>
                    </Button>
                    <Button
                    MinWidth="80" Margin="5" HorizontalAlignment="Center"
                    Content="{x:Static props:Resources.No}" Command="{Binding ResultButtonPressedCommand}" CommandParameter="No">
                        <Button.Style>
                            <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
                                <Setter Property="Button.Visibility" Value="Collapsed"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Buttons}" Value="YesNo">
                                        <Setter Property="Button.Visibility" Value="Visible"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Buttons}" Value="YesNoCancel">
                                        <Setter Property="Button.Visibility" Value="Visible"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Button.Style>
                    </Button>
                    <Button
                    MinWidth="80" Margin="5" HorizontalAlignment="Center"
                    Content="{x:Static props:Resources.Cancel}" Command="{Binding ResultButtonPressedCommand}" CommandParameter="Cancel">
                        <Button.Style>
                            <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
                                <Setter Property="Button.Visibility" Value="Collapsed"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Buttons}" Value="OKCancel">
                                        <Setter Property="Button.Visibility" Value="Visible"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Buttons}" Value="YesNoCancel">
                                        <Setter Property="Button.Visibility" Value="Visible"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Button.Style>
                    </Button>

                </StackPanel>
            </Border>
            
            <Grid.Style>
                <Style>
                    <Setter Property="Grid.Visibility" Value="Collapsed"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ContentView}" Value="{x:Null}">
                            <Setter Property="Grid.Visibility" Value="Visible"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Grid.Style>

        </Grid>
    </Grid>
    
</Window>
